home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / mkmf.biglib < prev    next >
Encoding:
Text File  |  1991-04-11  |  3.3 KB  |  106 lines

  1. #!/sprite/cmds/csh -f
  2. #
  3. # A script to generate (or regenerate) a library directory  Makefile
  4. # from a prototype Makefile.  If ./Makefile.proto exists, use it, else
  5. # use a common prototype.  This script is invoked for libraries that
  6. # have their sources distributed among a number of subdirectories;  this
  7. # script is invoked in the subdirectories.
  8. #
  9. # We assume we were invoked from mkmf.  Parameters passed in from mkmf
  10. # through environment variables:
  11. #
  12. #    DOMACHINES    names of machines we are supposed to run mkmf on
  13. #    MKMFDIR        directory containing prototype makefiles
  14. #    MKMFFLAGS    arguments to all mkmfs run recursively
  15. #    MACHINES    list of machine names (e.g. "sun2 sun3"), for
  16. #            which there are machine-dependent subdirectories
  17. #            (sun3.md, spur.md, etc.) of this directory.
  18. #    MAKEFILE    name of makefile to create
  19. #    SUBTYPE        information about what type of library this is:
  20. #            used to figure out where to install things.
  21. #
  22.  
  23. #
  24. # Argument processing.  (Generalized form, even though just one flag so far.)
  25. #
  26. while ($#argv >= 1)
  27.     if ("$1" == '-x') then
  28.     set echo
  29.     endif
  30.     shift
  31. end
  32.  
  33. set subtype=$SUBTYPE
  34. set lib=$cwd:h
  35. set lib=$lib:t
  36. set subdir=$cwd:t
  37. set pref='[a-z_A-Z]'
  38. set machines=($MACHINES)
  39. set domachines = ($DOMACHINES)
  40. set makefile=$MAKEFILE
  41. set distdir=($DISTDIR)
  42.  
  43. if (-e $makefile.proto) then
  44.     set proto=$makefile.proto
  45. else
  46.     set proto="${MKMFDIR}/Makefile.biglib"
  47. endif
  48.  
  49. echo "Generating $makefile for library subdirectory $lib/$cwd:t using $proto"
  50.  
  51. set nonomatch
  52. set hdrs =( ${subdir}*.h )
  53. if ("$hdrs" == "${subdir}*.h") set hdrs=()
  54. set pubHdrs=(`echo $hdrs | sed -e "s/[^ ]*Int.h//g"`)
  55. set allSrcs =( ${pref}*.[cylsp] )
  56. #
  57. # Check to see if there were any sources.  The first check (size == 1)
  58. # is only necessary because the second check will cause an error if
  59. # allSrcs contains more than 1024 bytes.
  60. #
  61. if ($#allSrcs == 1) then
  62.     if ("$allSrcs" == "${pref}*.[cylsp]") set allSrcs=()
  63. endif
  64. set mdSrcs =( *.md/${pref}*.[cylsp] )
  65. if ($#mdSrcs == 1) then
  66.     if ("$mdSrcs" == "*.md/${pref}*.[cylsp]") set mdSrcs=()
  67. endif
  68. set allSrcs=($allSrcs $mdSrcs)
  69. set lints = ( *.lint )
  70. if ("$lints" == "*.lint") set lints=()
  71. set manPages = (*.man)
  72. if ("$manPages" == "*.man") set manPages=()
  73.  
  74. #
  75. # Use sed to substitute various interesting things into the prototype
  76. # makefile. The code below is a bit tricky because some of the variables
  77. # being substituted in can be very long:  if the substitution is passed
  78. # to sed with "-e", the entire variable must fit in a single shell argument,
  79. # with a limit of 1024 characters.  By generating a separate script file
  80. # for the very long variables, the variables get passed through (to the
  81. # script file) as many arguments, which gets around the length problem.
  82. #
  83.  
  84. rm -f mkmf.tmp.sed
  85. echo s,"@(ALLSRCS)",$allSrcs,g > mkmf.tmp.sed
  86. echo s,"@(MANPAGES)",$manPages,g > mkmf.tmp.sed2
  87. cat $proto | sed -f mkmf.tmp.sed -f mkmf.tmp.sed2 \
  88.     -e "s,@(DATE),`date`,g" \
  89.     -e "s,@(LINTSRCS),$lints,g" \
  90.     -e "s,@(MACHINES),$machines,g" \
  91.     -e "s,@(MAKEFILE),$makefile,g" \
  92.     -e "s,@(MANPAGES),$manPages,g" \
  93.     -e "s,@(NAME),$lib,g" \
  94.     -e "s,@(PUBHDRS),$pubHdrs,g" \
  95.     -e "s,@(SUBDIR),$subdir,g" \
  96.     -e "s,@(TEMPLATE),$proto,g" \
  97.     -e "s,@(TYPE),$subtype,g" \
  98.     -e "s,@(DISTDIR),$distdir,g" \
  99.     > $makefile
  100. rm -f mkmf.tmp.sed mkmf.tmp.sed2
  101.  
  102. setenv PARENTDIR $cwd
  103. foreach i ($domachines)
  104.     (cd $i.md; mkmf $MKMFFLAGS -f md.mk)
  105. end
  106.